var fs = require('fs');
var path = require('path');

function iterationFolder(folderPath, folderPrefix) {
    folderPrefix = folderPrefix || "";
    var routers = [];
    require('fs').readdirSync(folderPath).forEach(function(file) {
        var filePath = path.join(folderPath, './' + file);
        if (fs.lstatSync(filePath).isFile()) {
            routers.push(new Route(filePath, folderPrefix + file));
        } else if (fs.lstatSync(filePath).isDirectory()) {
            routers = routers.concat(iterationFolder(filePath, file + "/"));
        }
    });
    return routers;
}

function Route(path, route) {
    this.path = "partials/" + route;
    this.route = '/partials/' + route.replace('.jade', '').replace('.js', '');
}

console.log(iterationFolder(path.join(__dirname, "./../views/partials")));
